#include<stdio.h>
int main()
{
	int count=0,i,j,n,a[1005],max=0;
	scanf("%d",&n);getchar();
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	a[n+1]=a[n]+1;
	for(i=1;i<=n-1;i++)
	{
		count=0;
		if(a[i]+1==a[i+1])
			for(j=i+1;j<=n;j++)
				if(a[j]+1==a[j+1])
					count++;
				else break;
		max=max>count?max:count;
	}
	printf("%d\n",max);
	return 0;
}
